/*=====================================================
 Copyright (C) ETERNAL<iqstar@ms24.hinet.net>
 URL : http://www.et99.net

请仔细阅读以下许可协议。当您使用本软体，您将自动成为本协议的一方并受到本协议的约束。

软体和文档受到台湾及中国大陆著作权法及国际条约的保护。您不得：
a)营利、出租或者出借软体或文档的任何部分。
b)反向工程、分解、反编译或者企图察看软体的源代码作为商业用途。
c)修改或者改变软体，或者与其他程式结合。

许可人保留软体及文档的所有权利和权益。您不能通过本许可协定获得软体的任何所有权和知识产权。
===================================================== */

//####### act tool #########
function act_click(a, b, c) {
    console.log(a, b, c)
    var foot = parent.foot.document.f1;
    if (c == null) {
        c = "";
    }
    localStorage.setItem('d_type', c);
    foot.f.value = a;
    foot.act.value = b;
    foot.temp_id.value = c;
    foot.action = "wog_act.php";
    foot.submit();
};

function foot_turn(a, b, c, d, e) {
    var foot = parent.foot.document.f1;
    var temp_s = "";
    foot.action = "wog_act.php";
    foot.temp_id2.value = "";
    foot.act.value = "";
    foot.f.value = "";
    foot.pay_id.value = "";
    foot.temp_id.value = "";
    foot.f.value = a;
    foot.act.value = b;
    foot.pay_id.value = c;
    foot.temp_id.value = d;
    var s2 = ",";
    if (e != null) {
        if (e.length != undefined) {
            for (var i = 0; i < e.length; i++) {
                if (e[i].checked == true) {
                    temp_s += s2 + e[i].value;
                }
            }
            temp_s = temp_s.substr(1, temp_s.length);
        } else {
            temp_s = e.value;
        }
        foot.temp_id2.value = temp_s;
    }
    foot.submit();
};

function act_gclick(a, b, c) {
    var foot = parent.foot.document.f1;
    if (c == null) {
        c = "";
    }
    foot.f.value = a;
    foot.act.value = b;
    foot.temp_id.value = c;
    foot.action = "wog_group.php";
    foot.submit();
};

function foot_gturn(a, b, c, d, e) {
    var foot = parent.foot.document.f1;
    var temp_s = "";
    foot.action = "wog_group.php";
    foot.temp_id2.value = "";
    foot.act.value = "";
    foot.f.value = "";
    foot.pay_id.value = "";
    foot.temp_id.value = "";
    foot.f.value = a;
    foot.act.value = b;
    foot.pay_id.value = c;
    foot.temp_id.value = d;
    var s2 = ",";
    if (e != null) {
        if (e.length != undefined) {
            for (var i = 0; i < e.length; i++) {
                if (e[i].checked == true) {
                    temp_s += s2 + e[i].value;
                }
            }
            temp_s = temp_s.substr(1, temp_s.length);
        } else {
            temp_s = e.value;
        }
        foot.temp_id2.value = temp_s;
    }
    foot.submit();
};

function th_submit(b, s, a) {
    var thisfrom = b;
    thisfrom.temp_id2.value = s;
    thisfrom.temp_id.value = a;
    thisfrom.submit();
};
var countDownTimer = null;

/**
 * 自动战斗倒计时
 * @constructor
 */
function CountDown() {
    if (countDownTimer) {
        clearTimeout(countDownTimer)
        countDownTimer = null
    }
    var foot = UI.set_target;
    if (counts > 0) {
        foot.getElementById("con_fight").disabled = 'disabled';
        foot.menu.ats1.disabled = 'disabled';
        foot.menu.ats1.value = "离冒险" + counts + "秒";
        countDownTimer = setTimeout(function () {
            counts--;
            new CountDown()
        }, 1000)
    } else {
        foot.menu.ats1.disabled = false;
        foot.menu.ats1.value = "开始冒险";
        foot.getElementById("con_fight").disabled = false;
        foot.getElementById("con_fight").setAttribute('onclick', 'parent.fight_fast();');
        foot.getElementById("con_fight").style.display = 'inline-block';
        foot.getElementById("con_fight").innerHTML = '继续冒险';
    }
};

function cd(s) {
    if (counts === 0) {
        var date = new Date();
        start_time = date.getTime() / 1000;
    }
    counts = +s;
    if (countDownTimer) {
        clearTimeout(countDownTimer)
        countDownTimer = null
    }
    CountDown()
};

function inCountDown() {
    var now = new Date();
    now = Date.parse(now) / 1000;
    var x = parseInt(counts - (now - start_time), 10);
    var f1 = parent.wog_view.document.f1;
    if (f1) {
        f1.ppp.value = "请等待" + x + "秒";
    }
    if (x > 0) {
        timerID = setTimeout("inCountDown()", 1300);
        f1.ppp.disabled = true;
    } else {
        f1.ppp.disabled = false;
        f1.ppp.value = "角色登入";
    }
};

function incd(s) {
    alert("线上人数额满,请稍后进入");
    start_time = new Date();
    start_time = Date.parse(start_time) / 1000;
    setup_cs(s);
    window.setTimeout('inCountDown()', 1300);
};

function hidebox(a) {
    if (f.getElementById("DivShim")) {
        f.getElementById("DivShim").style.display = "none";
    }
    if (f.getElementById(a)) {
        f.getElementById(a).style.display = "none";
    }
};

function wog_message_box(a, b, c, d, x1, x2) {
    set_window();
    let _docWidth = UI.window_w;
    let _docHeight = UI.window_h;
    let _width = 360;
    let _height = 10;
    var temp_ex = "";
    var window_name = "wog_message_box";
    switch (b) {
        case 0: //任务信息,作战内容
            _width = 620;
            switch (c) {
                case 1:
                    _width = 260;
                    a = '<center>' + job_s[a] + '</center>';
                    break;
                case 2:
                    _width = 280;
                    a = '<div class=b1>' + a + '</div>';
                    break;
                case 3:
                    _width = 420;
                    var s1 = a.split(",");
                    var r = s1[2].split(":");
                    var r_item = '';
                    switch (r[0]) {
                        case "wp":
                            r_item = wp_name[r[1]] + '：' + r[2];
                            break;
                        case "ex":
                            r_item = ex_name[r[1]] + '：' + r[2];
                            break;
                        case "item":
                            r_item = g_item[r[1]] + '：' + r[2];
                            break;
                    }
                    switch (d) {
                        case 1:
                            var n = s1[1].split(":");
                            var n2 = n[1].split("\|");
                            a = '<div class=message_box>' + s1[0] + '<br>完成条件 → 生产' + wp_name[n[0]] + '：' + n2[1] + '/' + n2[0] + '<br>任务奖励 → ' + r_item + '</div>';
                            break;
                        case 2:
                            var n = s1[1].split(":");
                            a = '<div class=message_box>' + s1[0] + '<br>完成条件 → 侦查‘' + n[0] + '’<br>任务奖励 → ' + r_item + '</div>';
                            break;
                        case 3:
                            var n = s1[1].split(":");
                            a = '<div class=message_box>' + s1[0] + '<br>完成条件 → 攻打‘' + n[0] + '’<br>任务奖励 → ' + r_item + '</div>';
                            break;
                        case 4:
                            var n = s1[1].split(":");
                            var n2 = n[3].split("\|");
                            a = '<div class=message_box>' + s1[0] + '<br>完成条件 → 运输‘' + wp_name[n[2]] + '：' + n2[1] + '/' + n2[0] + '’，至‘' + n[0] + '’<br>任务奖励 → ' + r_item + '</div>';
                            break;
                    }
                    break;
                default:
                    a = '<div class=message_box>' + a + '</div>';
                    break;
            }
            a = a.replace(/&n/g, "<br>");
            temp_ex += '<table width=100% cellspacing="0" cellpadding="0">';
            temp_ex += '<tr><td >' + a + '</td></tr>';
            temp_ex += '</table>';
            break;
        case 1: //物品类
            var s1 = a.split(",");
            // 是否绑定
            const is_bind = +s1[25] === 1;
            // 品质
            const quality = getEqQuality([s1[26]]);
            switch (c) {
                //点击弹出武器防具道具
                case 1:
                    window_name = "wog_message_box";
                    if (a != "") {
                        console.log(s1)
                        temp_ex = `
            <div class="text-center font-size-16 p-5" style="color:${quality.color}">${s1[0]}</div>
            <div class="font-size-12 text-grey text-center py-10"><span style="color: ${quality.color}">${quality.name}</span>${is_bind ? ' | <span class="text-danger">绑定</span>' : ''} | 价格：${s1[20]}</div>
            <div class="avg avg-2 m-2-reverse">
                <div class="avg-item p-2"><div class="status-view-data"><div class="status-view-data-label min">职业</div><div class="status-view-data-value flex-1 width-0">${s1[19]}</div></div></div>
                <div class="avg-item p-2"><div class="status-view-data"><div class="status-view-data-label min">属性</div><div class="status-view-data-value flex-1 width-0">${s1[21]}</div></div></div>
                <div class="avg-item p-2"><div class="status-view-data"><div class="status-view-data-label min">洞数</div><div class="status-view-data-value flex-1 width-0">${s1[22]}</div></div></div>
                <div class="avg-item p-2"><div class="status-view-data"><div class="status-view-data-label min">精炼</div><div class="status-view-data-value flex-1 width-0">${s1[23]}</div></div></div>
            </div>
                <div class="section-title mt-10">攻防加成</div>
            <div class="overflow-hidden">
                <div class="avg avg-2 m-2-reverse">
                    <div class="avg-item p-2"><div class="status-view-data"><div class="status-view-data-label min">物攻</div><div class="status-view-data-value flex-1 width-0">${bf_c(s1[1])}</div></div></div>
                    <div class="avg-item p-2"><div class="status-view-data"><div class="status-view-data-label min">魔攻</div><div class="status-view-data-value flex-1 width-0">${bf_c(s1[2])}</div></div></div>
                    <div class="avg-item p-2"><div class="status-view-data"><div class="status-view-data-label min">物防</div><div class="status-view-data-value flex-1 width-0">${bf_c(s1[3])}</div></div></div>
                    <div class="avg-item p-2"><div class="status-view-data"><div class="status-view-data-label min">魔防</div><div class="status-view-data-value flex-1 width-0">${bf_c(s1[4])}</div></div></div>
                </div>
            </div>
            <div class="section-title mt-10">属性加成</div>
            <div class="avg avg-2 m-2-reverse">
                <div class="avg-item p-2"><div class="status-view-data"><div class="status-view-data-label min">HP</div><div class="status-view-data-value flex-1 width-0">${bf_c(s1[24] || '0')}</div></div></div>
                <div class="avg-item p-2"><div class="status-view-data"><div class="status-view-data-label min">力量</div><div class="status-view-data-value flex-1 width-0">${bf_c(s1[5])}</div></div></div>
                <div class="avg-item p-2"><div class="status-view-data"><div class="status-view-data-label min">智力</div><div class="status-view-data-value flex-1 width-0">${bf_c(s1[6])}</div></div></div>
                <div class="avg-item p-2"><div class="status-view-data"><div class="status-view-data-label min">敏捷</div><div class="status-view-data-value flex-1 width-0">${bf_c(s1[7])}</div></div></div>
                <div class="avg-item p-2"><div class="status-view-data"><div class="status-view-data-label min">生命</div><div class="status-view-data-value flex-1 width-0">${bf_c(s1[11])}</div></div></div>
                <div class="avg-item p-2"><div class="status-view-data"><div class="status-view-data-label min">体质</div><div class="status-view-data-value flex-1 width-0">${bf_c(s1[9])}</div></div></div>
                <div class="avg-item p-2"><div class="status-view-data"><div class="status-view-data-label min">信仰</div><div class="status-view-data-value flex-1 width-0">${bf_c(s1[10])}</div></div></div>
                <div class="avg-item p-2"><div class="status-view-data"><div class="status-view-data-label min">魅力</div><div class="status-view-data-value flex-1 width-0">${bf_c(s1[8])}</div></div></div>
            </div>
            <div class="section-title mt-10">技能</div>
           <div class="status-view-data"><div class="status-view-data-value flex-1 width-0">${s1[12]}</div></div>

            <div class="section-title mt-10">能力限制</div>
            <div class="text-white">${arm_need_status(s1[14], s1[15], s1[16], s1[17])}</div>
            ${s1[13] !== '' ? '<div>' + s1[13] + '</div>' : ''}`;
                        // temp_ex += '<table class="arm-view-table">';
                        // temp_ex += '<tr><td colspan="4" ' + s1[0] + '</td></tr>';
                        // temp_ex += '<tr><td>物攻</td><td>魔攻</td><td>物防</td><td>魔防</td></tr>';
                        // temp_ex += '<tr><td>' + bf_c(s1[1]) + '</td><td>' + bf_c(s1[2]) + '</td><td>' + bf_c(s1[3]) + '</td><td>' + bf_c(s1[4]) + '</td></tr>';
                        // temp_ex += '<tr><td colspan="4"><hr></td></tr>'
                        // temp_ex += '<tr><td>职业</td><td>属性</td><td>洞数</td><td>精炼</td></tr>';
                        // temp_ex += '<tr><td>' + s1[19] + '</td><td>' + s_status[s1[21]] + '</td><td>' + s1[22] + '</td><td>' + s1[23] + '</td></tr>';
                        // temp_ex += item_detail(s1[5], s1[6], s1[7], s1[8], s1[9], s1[10], s1[11], s1[24]);
                        // temp_ex += '<tr><td colspan="4"><hr></td></tr>';
                        // temp_ex += '<tr><td colspan="2">技能</td><td colspan="2">价格</td></tr>';
                        // temp_ex += '<tr><td colspan="2">' + s1[12] + '</td><td colspan="2">' + s1[20] + '</td></tr>';
                        // temp_ex += '<tr ><td colspan="4">能力限制</td></tr>';
                        // temp_ex += '<tr><td colspan="4">' + arm_need_status(s1[14], s1[15], s1[16], s1[17]) + '</td></tr>';
                    }
                    // if (s1[13] != "") {
                    //     temp_ex += '<tr><td colspan="4">' + s1[13];
                    //     temp_ex += '</td></tr>';
                    // }
                    // temp_ex += '</table>';
                    break;
                case 2: //魔石
                    if (a != "") {
                        temp_ex += '<table bgcolor="' + wog_m_box_color1 + '" width=100% cellspacing="0" cellpadding="0"><tr><td><table width=100% cellspacing="1" cellpadding="1">';
                        temp_ex += '<tr bgcolor="' + wog_m_box_color1 + '"><td colspan="4">' + s1[11] + '</td></tr>';
                        temp_ex += '<tr bgcolor="' + wog_m_box_color1 + '"><td>物攻</td><td>魔攻</td><td>物防</td><td>魔防</td></tr>';
                        temp_ex += '<tr><td>' + s1[0] + '</td><td>' + s1[1] + '</td><td>' + s1[2] + '</td><td>' + s1[3] + '</td></tr>';
                        temp_ex += '<tr bgcolor="' + wog_m_box_color1 + '"><td>敏捷</td><td>力量</td><td colspan="2">HP</td></tr>';
                        temp_ex += '<tr><td>' + s1[4] + '</td><td>' + s1[5] + '</td><td colspan="2">' + s1[6] + '</td></tr>';
                        temp_ex += '<tr bgcolor="' + wog_m_box_color1 + '"><td>体质</td><td>智力</td><td>魅力</td><td>信仰</td></tr>';
                        temp_ex += '<tr><td>' + s1[7] + '</td><td>' + s1[8] + '</td><td>' + s1[9] + '</td><td>' + s1[10] + '</td></tr></table></td></tr></table>';
                    }
                    break;
                case 3: //佣兵
                    if (a != "") {
                        temp_ex += '<table bgcolor="' + wog_m_box_color1 + '" width=100% cellspacing="0" cellpadding="0"><tr><td><table width=100% cellspacing="1" cellpadding="1">';
                        temp_ex += '<tr bgcolor="' + wog_m_box_color1 + '"><td colspan="5">' + s1[0] + '</td></tr>';
                        temp_ex += '<tr bgcolor="' + wog_m_box_color1 + '"><td>战斗次数</td><td>金钱</td><td>宝物</td><td>经验</td><td>死亡消耗</td></tr>';
                        temp_ex += '<tr><td>' + s1[1] + '</td><td>' + s1[2] + '%</td><td>' + s1[3] + '%</td><td>' + s1[4] + '%</td><td>' + s1[5] + '</td></tr>';
                        temp_ex += '</table></td></tr></table>';
                    }
                    break;
                case 4: //商店用物品资讯
                    if (a != "") {
                        _width = 460;
                        _height = 120;
                        temp_ex += '<table width=100% cellspacing="1" cellpadding="1">';
                        temp_ex += '<tr bgcolor="' + wog_m_box_color1 + '"><td colspan="4">' + s1[0] + '</td></tr>';
                        temp_ex += item_detail(s1[1], s1[2], s1[3], s1[4], s1[5], s1[6], s1[7], s1[13]);
                        temp_ex += '<tr bgcolor="' + wog_m_box_color1 + '"><td>洞数</td><td>精炼</td><td>技能</td><td>价格</td></tr>';
                        temp_ex += '<tr><td>' + s1[10] + '</td><td>' + s1[11] + '</td><td>' + s1[8] + '</td><td>' + s1[12] + '</td></tr>';
                        if (s1[9]) {
                            temp_ex += '<tr><td colspan="4">';
                            var s2 = s1[9].split(";");
                            for (var i = 0; i < s2.length; i++) {
                                temp_ex += " " + s2[i];
                            }
                            temp_ex += '</td></tr>';
                        }
                        temp_ex += '</table>';
                    }
                    break;
            }
            break;
        case 2: //公会内政军备
            var s1 = a.split(",");
            switch (c) {
                case 1: //兵种
                    if (a != "") {
                        temp_ex += '<table bgcolor="' + wog_m_box_color1 + '" width=100% cellspacing="0" cellpadding="0"><tr><td><table width=100% cellspacing="1" cellpadding="1">';
                        temp_ex += '<tr bgcolor="' + wog_m_box_color1 + '"><td>' + wp_name[1] + '</td><td>' + wp_name[2] + '</td><td>' + wp_name[3] + '</td><td>' + wp_name[4] + '</td></tr>';
                        temp_ex += '<tr><td>' + s1[0] + '</td><td>' + s1[1] + '</td><td>' + s1[2] + '</td><td>' + s1[3] + '</td></tr>';
                        temp_ex += '<tr bgcolor="' + wog_m_box_color1 + '"><td>' + wp_name[5] + '</td><td>' + wp_name[6] + '</td><td>' + wp_name[7] + '</td><td>' + wp_name[8] + '</td></tr>';
                        temp_ex += '<tr><td>' + s1[4] + '</td><td>' + s1[5] + '</td><td>' + s1[6] + '</td><td>' + s1[7] + '</td></tr>';
                        temp_ex += '<tr bgcolor="' + wog_m_box_color1 + '"><td>' + wp_name[9] + '</td></tr>';
                        temp_ex += '<tr><td>' + s1[8] + '</td></tr></table></td></tr></table>';
                    }
                    break;
                case 2: //资源
                    if (a != "") {
                        temp_ex += '<table bgcolor="' + wog_m_box_color1 + '" width=100% cellspacing="0" cellpadding="0"><tr><td><table width=100% cellspacing="1" cellpadding="1">';
                        temp_ex += '<tr bgcolor="' + wog_m_box_color1 + '"><td>煤</td><td>木材</td><td>石块</td><td>石油</td></tr>';
                        temp_ex += '<tr><td>' + s1[0] + '</td><td>' + s1[1] + '</td><td>' + s1[2] + '</td><td>' + s1[3] + '</td></tr>';
                        temp_ex += '<tr bgcolor="' + wog_m_box_color1 + '"><td>黄金</td><td>酒</td><td>大麦</td><td>香烟</td></tr>';
                        temp_ex += '<tr><td>' + s1[4] + '</td><td>' + s1[5] + '</td><td>' + s1[6] + '</td><td>' + s1[7] + '</td></tr>';
                        temp_ex += '<tr bgcolor="' + wog_m_box_color1 + '"><td>铁</td><td>皮毛</td><td>丝线</td><td>珍珠</td></tr>';
                        temp_ex += '<tr><td>' + s1[8] + '</td><td>' + s1[9] + '</td><td>' + s1[10] + '</td><td>' + s1[11] + '</td></tr></table></td></tr></table>';
                    }
                    break;
                case 3: //资源+兵种
                    temp_ex += '<table bgcolor="' + wog_m_box_color1 + '" width=100% cellspacing="0" cellpadding="0"><tr><td><table width=100% cellspacing="1" cellpadding="1">';
                    temp_ex += '<tr bgcolor="' + wog_m_box_color1 + '"><td colspan="4">据点防御力 ' + s1[24] + '/' + s1[25] + '</td></tr>';
                    temp_ex += '<tr bgcolor="' + wog_m_box_color1 + '"><td>' + wp_name[1] + '</td><td>' + wp_name[2] + '</td><td>' + wp_name[3] + '</td><td>' + wp_name[4] + '</td></tr>';
                    temp_ex += '<tr><td>' + s1[12] + '</td><td>' + s1[13] + '</td><td>' + s1[14] + '</td><td>' + s1[15] + '</td></tr>';
                    temp_ex += '<tr bgcolor="' + wog_m_box_color1 + '"><td>' + wp_name[5] + '</td><td>' + wp_name[6] + '</td><td>' + wp_name[7] + '</td><td>' + wp_name[8] + '</td></tr>';
                    temp_ex += '<tr><td>' + s1[16] + '</td><td>' + s1[17] + '</td><td>' + s1[18] + '</td><td>' + s1[19] + '</td></tr>';
                    temp_ex += '<tr bgcolor="' + wog_m_box_color1 + '"><td>' + wp_name[9] + '</td><td>' + wp_name[10] + '</td><td>' + wp_name[11] + '</td><td>' + wp_name[12] + '</td></tr>';
                    temp_ex += '<tr><td>' + s1[20] + '</td><td>' + s1[21] + '</td><td>' + s1[22] + '</td><td>' + s1[23] + '</td></tr></table></td></tr></table>';

                    temp_ex += '<table bgcolor="' + wog_m_box_color1 + '" width=100% cellspacing="0" cellpadding="0"><tr><td><table width=100% cellspacing="1" cellpadding="1">';
                    temp_ex += '<tr bgcolor="' + wog_m_box_color1 + '"><td>煤</td><td>木材</td><td>石块</td><td>石油</td></tr>';
                    temp_ex += '<tr><td>' + s1[0] + '</td><td>' + s1[1] + '</td><td>' + s1[2] + '</td><td>' + s1[3] + '</td></tr>';
                    temp_ex += '<tr bgcolor="' + wog_m_box_color1 + '"><td>黄金</td><td>酒</td><td>大麦</td><td>香烟</td></tr>';
                    temp_ex += '<tr><td>' + s1[4] + '</td><td>' + s1[5] + '</td><td>' + s1[6] + '</td><td>' + s1[7] + '</td></tr>';
                    temp_ex += '<tr bgcolor="' + wog_m_box_color1 + '"><td>铁</td><td>皮毛</td><td>丝线</td><td>珍珠</td></tr>';
                    temp_ex += '<tr><td>' + s1[8] + '</td><td>' + s1[9] + '</td><td>' + s1[10] + '</td><td>' + s1[11] + '</td></tr></table></td></tr></table>';
                    break;
                case 4:
                    temp_ex += '<table bgcolor="' + wog_m_box_color1 + '" width=100% cellspacing="0" cellpadding="0"><tr><td><table width=100% cellspacing="1" cellpadding="1">';
                    temp_ex += '<tr bgcolor="' + wog_m_box_color1 + '"><td colspan="4">公会名称</td></tr>';
                    temp_ex += '<tr><td colspan="4">' + s1[0] + '</td></tr>';
                    temp_ex += '<tr bgcolor="' + wog_m_box_color1 + '"><td>人数</td><td>等级</td><td>气候</td><td>地形</td></tr>';
                    temp_ex += '<tr><td>' + s1[1] + '</td><td>' + s1[2] + '</td><td>' + g_weather[s1[3]] + '</td><td>' + g_area_type[s1[4]] + '</td></tr>';
                    temp_ex += '</table></td></tr></table>';
                    break;
            }
            break;
        case 3: //合成信息
            _width = 460;
            _height = 120;
            var s2 = c.split(",");
            temp_ex += '<table bgcolor="' + wog_m_box_color1 + '" width=100% cellspacing="0" cellpadding="0"><tr><td><table width=100% cellspacing="1" cellpadding="1" >';
            temp_ex += '<tr bgcolor="' + wog_m_box_color1 + '"><td colspan="4">制作“' + s2[0] + '”需要下列物品</td></tr>';
            temp_ex += '<tr><td colspan="4">' + a + '</td></tr>';
            if (s2[9] != "") {
                temp_ex += '<tr bgcolor=' + tr_bgcolor2 + '><td colspan="4">需完成任务 : ' + s2[9] + '</td></tr>';
            }
            temp_ex += item_detail(s2[1], s2[2], s2[3], s2[6], s2[5], s2[7], s2[4], s2[8]);
            temp_ex += '</table></td></tr></table>';
            break;
        case 4: //技能信息
            _width = 460;
            _height = 120;
            var s1 = a.split(",");
            temp_ex += '<table bgcolor="' + wog_m_box_color1 + '" width=100% cellspacing="0" cellpadding="0"><tr><td><table width=100% cellspacing="1" cellpadding="1">';
            temp_ex += '<tr bgcolor="' + wog_m_box_color1 + '"><td colspan="4">“' + s1[0] + '”</td></tr>';
            temp_ex += '<tr bgcolor="' + wog_m_box_color1 + '"><td>回合数</td><td>消费SP</td><td>技能说明</td></tr>';
            temp_ex += '<tr><td>' + s1[1] + '</td><td>' + s1[2] + '</td><td>' + s1[3] + '</td></tr>';
            temp_ex += '</table></td></tr></table>';
            break;
        // case 5: //进入游戏后的提示
        //     window_name = "wog_well_box";
        //     _width = 720;
        //     _height = 180;
        //     a = '<div class=well_box>' + a + '</div>';
        //     temp_ex += '<table width=100% cellspacing="0" cellpadding="0">';
        //     temp_ex += '<tr><td >' + a + '</td></tr>';
        //     temp_ex += '</table>';
        //     break;
    }
    _docHeight = (_docHeight / 3) - (_height / 2);
    _docWidth = (_docWidth / 2) - (_width / 2);
    if (x1 != null && x2 != null) {
        const rootEl = f.body;
        if (rootEl.scrollTop > x2) {
            x2 += rootEl.scrollTop;
        }
        _docWidth = x1 + 35;
        _docHeight = x2 - 10;
    }
    if (temp_ex) {
        var wog_message_box_html = `<div class="wog-message-container ${b == 0 ? 'wog-message-mission-container' : ''}"><div class="wog-message-detail-fixed pos-r"><a class="close-icon close-icon-fixed" title="关闭" href="javascript:parent.hidebox('${window_name}');"target="mission"></a>`;
        wog_message_box_html += temp_ex;
        wog_message_box_html += '</div></div>'
        f.getElementById(window_name).innerHTML = wog_message_box_html;
        f.getElementById(window_name).style.display = "block";
    }
};

/**
 * 物品详情
 * @param a1
 * @param a2
 * @param a3
 * @param a4
 * @param a5
 * @param a6
 * @param a7
 * @param a8
 * @returns {string}
 */
function item_detail(a1, a2, a3, a4, a5, a6, a7, a8) {
    var temp_ex = "";
    temp_ex += '<tr bgcolor="' + wog_m_box_color1 + '"><td>力量</td><td>智力</td><td>敏捷</td><td>魅力</td></tr>';
    temp_ex += '<tr><td>' + bf_c(a1) + '</td><td>' + bf_c(a2) + '</td><td>' + bf_c(a3) + '</td><td>' + bf_c(a4) + '</td></tr>';
    temp_ex += '<tr bgcolor="' + wog_m_box_color1 + '"><td>体质</td><td>信仰</td><td>生命</td><td>HP</td></tr>';
    temp_ex += '<tr><td>' + bf_c(a5) + '</td><td>' + bf_c(a6) + '</td><td>' + bf_c(a7) + '</td><td>' + bf_c(a8) + '</td></tr>';
    return temp_ex;
};

/**
 * 游戏菜单
 */
function foot_fire() {
    w_m('<form action="wog_act.php" method="post" name="menu" target="mission">' + menu_table1 + '<tr>');
    w_m('<div class="game-menu">')
    w_m('<button type="button" class="game-menu-btn" style="display: none" id="con_fight">冒险旅程</button>');
    w_m('<input type="button" class="game-menu-btn" value="冒险开始" name="ats1" onClick="parent.ad_view()" accesskey="a">')
    w_m('<input type="button" class="game-menu-btn" value="角色状态" onClick="parent.act_click(\'chara\',\'status_view\')" accesskey="s">')
    // w_m('<input type="button" class="game-menu-btn" value="冠军状态" onClick="parent.act_click(\'chara\',\'cp\')" accesskey="o">')
    w_m('<input type="button" class="game-menu-btn" value="背包" onClick="parent.arm_select(1)" accesskey="e">');
    // w_m('<input type="button" class="game-menu-btn" value="新背包" onclick="parent.document.getElementById(\'views\').src=\'./../views/player-items.php\'" accesskey="e">');
    w_m('<input type="button" class="game-menu-btn" value="任务手册" onClick="parent.mission_ed()" accesskey="b">');
    w_m('<input type="button" class="game-menu-btn" value="技能手册" onClick="parent.act_click(\'skill\',\'view\')" accesskey="k">');
    w_m('</div>');
    w_m('<div class="game-menu mt-10">');
    w_m('<input type="button" class="game-menu-btn" value="商店街" onClick="parent.select_store()" accesskey="c">');
    w_m('<input type="button" class="game-menu-btn" value="住宿" onClick="parent.act_click(\'store\',\'hotel\')" accesskey="h">');
    w_m('<input type="button" class="game-menu-btn" value="银行仓库" onClick="parent.act_click(\'arm\',\'depot_list\')" accesskey="d">');
    w_m('<input type="button" class="game-menu-btn" value="情报中心" onClick="parent.act_click(\'system\',\'view1\')" accesskey="q">');
    w_m('<span class="px-10 search-player-bar"><span class="text-white">侦查对象</span>(<a href="javascript:parent.noname()" class="text-white">取消</a>)<input type="text" name="towho" size="7"></span>');
    w_m('<input type="button" class="game-menu-btn" value="侦查" onClick="parent.act_click(\'chara\',\'view2\',document.menu.towho.value)" accesskey="v">');
    w_m(`<button type="button" class="game-menu-btn" id="bgmSwitch" onclick="bgmToggle()">${!localStorage.getItem('BGMStatus') || localStorage.getItem('BGMStatus') === 'stop' ? '音乐停止' : '播放中'}</button>`);
    w_m('</div>')
    w_m('</form>');
    var a = Gookie("wog_setui");
    setUI(parseInt(a));
    switch (UI.set_frame) {
        case 1:
            dfoot = f;
            p_m();
            UI.set_target = f;
            break;
        case 2:
            dfoot = parent.foot.document;
            // w_m('<table cellspacing="0" cellpadding="0" align="center"><tr><td valign="top" align="center" ><b><a href="http://www.et99.net/viewforum.php?f=36" target="_blank">WOG</a> V4 Copyright (C) <a href="http://www.et99.net" target="_blank">ETERNAL</a></b></td></tr></table>');
            p_m();
            UI.set_target = dfoot;
            break;
        default:
            setUI(1);
            dfoot = parent.foot.document;
            // w_m('<table cellspacing="0" cellpadding="0" align="center"><tr><td valign="top" align="center" ><b><a href="http://www.et99.net/viewforum.php?f=36" target="_blank">WOG</a> V4 Copyright (C) <a href="http://www.et99.net" target="_blank">ETERNAL</a></b></td></tr></table>');
            p_m();
            UI.set_target = dfoot;
            break;
    }
    Drag.init(f.getElementById("wog_menu"));
};

function open_chat(team_id) {
    if (UI.set_frame == 1) {
        w_chat(chat_table1 + '<tr><td><b>Online FF Battle - <a href="http://www.et99.net/wog4/index.htm" target="_blank">WOG</a> V4 Copyright (C) <a href="http://www.et99.net" target="_blank">ETERNAL</a></b></td><td><table align="right"><tr><td><a href="javascript:parent.chat_resize()" style="text-decoration:none;">↗</a></td></tr></table></td></tr><tr><td width="520" height="150" id="chat_table" colspan="2" ><iframe id="frame_chat" name="frame_chat" src="./wog_chat/wog_chat.php" scrolling="no" frameborder="0" marginheight="0" marginwidth="0" width="100%" height="100%"></iframe></td></tr>' + temp_table2);
    } else {
        w_chat(chat_table1 + '<tr><td width="620" height="148" id="chat_table" ><iframe id="frame_chat" name="frame_chat" src="./wog_chat/wog_chat.php" scrolling="no" frameborder="0" marginheight="0" marginwidth="0" width="100%" height="100%"></iframe></td></tr>' + temp_table2);
    }
    p_chat();
    Drag.init(f.getElementById("wog_chat"));
    if (return_well_box() == "") {
        act_click('chara', 'well');
    }
};

function chat_resize() {
    switch (chat_size) {
        case 1:
            f.getElementById("chat_table").width = 560;
            f.getElementById("chat_table").height = 150;
            chat_size = 2;
            break;
        case 2:
            f.getElementById("chat_table").width = 620;
            f.getElementById("chat_table").height = 180;
            chat_size = 3;
            break;
        case 3:
            f.getElementById("chat_table").width = 650;
            f.getElementById("chat_table").height = 280;
            chat_size = 4;
            break;
        case 4:
            f.getElementById("chat_table").width = 520;
            f.getElementById("chat_table").height = 100;
            chat_size = 1;
            break;
    }
};

function msg_to_chat(a1) {
    var temp_f = null;
    if (UI.set_frame == 1) {
        temp_f = wog_view.frame_chat;
    } else {
        temp_f = foot.frame_chat;
    }
    temp_f.goldset('系统', '0', '<font color=red>' + a1 + '</font>', '', '');
};

function Sookie(name, value) {
    document.cookie = name + "=" + value
};

function Gookie(name) {
    var arg = name + "=";
    var alen = arg.length;
    var clen = document.cookie.length;
    var i = 0;
    while (i < clen) {
        var j = i + alen;
        if (document.cookie.substring(i, j) == arg)
            return GookieVal(j);
        i = document.cookie.indexOf(" ", i) + 1;
        if (i == 0) break;
    }
    return null;
};

function GookieVal(offset) {
    var endstr = document.cookie.indexOf(";", offset);
    if (endstr == -1)
        endstr = document.cookie.length;
    return document.cookie.substring(offset, endstr);
};

function srhCount(srhStr) {
    var tmpData = vData.split(",");
    var tmpResult = 0;
    tmpNum = "";
    var tempvdata = "";
    for (var i = 0; i < tmpData.length; i++) {
        if (tmpData[i].indexOf("*") > 0 || tmpData[i].indexOf(":") > 0) {
            if (tmpData[i].indexOf("*") > 0) {
                var s1 = tmpData[i].split("*");
            }
            if (tmpData[i].indexOf(":") > 0) {
                var s1 = tmpData[i].split(":");
            }
            if (s1[0] == srhStr) {
                tmpResult = tmpResult + 1;
                tmpNum = tmpNum + "," + s1[1];
            } else {
                tempvdata = tempvdata + "," + tmpData[i];
            }
        } else {
            if (tmpData[i] == srhStr) {
                tmpResult = tmpResult + 1;
            } else {
                tempvdata = tempvdata + "," + tmpData[i];
            }
        }
    }
    vData = tempvdata.substr(1, tempvdata.length);
    if (tmpNum != "") {
        tmpNum = tmpNum.substr(1, tmpNum.length);
    }
    return tmpResult;
};

function bf_c(a1) {
    if (a1 && a1.indexOf("+") > -1) {
        var s1 = a1.split("+");
        a1 = s1[0] + buff1 + s1[1] + buff2;
    }
    return a1;
}

function yesname(s) {
    UI.set_target.menu.towho.value = s;
};

function noname() {
    UI.set_target.menu.towho.value = '';
};

function setUI(a) {
    switch (a) {
        case 1:
            UI.set_frame = 2;
            UI.set_rows = "0,39,*,0,0,153,0";
            Sookie("wog_setui", 1);
            break;
        case 2:
            Sookie("wog_setui", 2);
            UI.set_frame = 1;
            UI.set_rows = "0,39,*,0,0,0,0";
            UI.set_center_w = "850";
            UI.set_fight_w = "600";
            break;
        default:
            Sookie("wog_setui", 1);
            break;
    }
};

function set_well_box(a1) {
    var a = Gookie("wog_setwell");
    if (a == "1") {
        Sookie("wog_setwell", 0);
    } else {
        Sookie("wog_setwell", 1);
    }
};

function return_well_box() {
    var a = Gookie("wog_setwell");
    if (a == "1") {
        return "checked";
    } else {
        return "";
    }
};

function checkAll(name) {
    var el = f.getElementsByTagName('input');
    var len = el.length;
    for (var i = 0; i < len; i++) {
        if ((el[i].type == "checkbox") && (el[i].name == name)) {
            if (el[i].checked == true) {
                el[i].checked = false;
            } else {
                el[i].checked = true;
            }
        }
    }
};

function get_towho() {
    return UI.set_target.menu.towho.value;
};

function btn_disabled(a1) {
    f.getElementById(a1).disabled = true;
    window.setTimeout("btn_not_disabled('" + a1 + "')", 1500);
};

function btn_not_disabled(a1) {
    f.getElementById(a1).disabled = false;
};

function set_arm_tochat(a1, a2) {
    var temp_f = null;
    if (UI.set_frame == 1) {
        temp_f = parent.wog_view.frame_chat.chat_in.document.f1;
    } else {
        temp_f = parent.foot.frame_chat.chat_in.document.f1;
    }
    if (!temp_f) {
        return;
    }
    var temp = temp_f.chat_temp.value;
    var s_num = temp.indexOf("[");
    var e_num = temp.indexOf("]");
    if (s_num > -1 && e_num > 0) {
        var temp1 = temp.substr(0, s_num);
        var temp2 = temp.substr(e_num + 1, temp.length - e_num);
        temp = temp1 + temp2;
    }
    temp_f.chat_temp.value = temp + "[" + a1 + "]";
    temp_f.item_id_temp.value = a2;
};

function addBookmarkForBrowser(sTitle, sUrl) {

    if (window.sidebar && window.sidebar.addPanel) {
        addBookmarkForBrowser = function (sTitle, sUrl) {
            window.sidebar.addPanel(sTitle, sUrl, "");
        }
    } else if (window.external) {
        addBookmarkForBrowser = function (sTitle, sUrl) {
            window.external.AddFavorite(sUrl, sTitle);
        }
    } else {
        addBookmarkForBrowser = function () {
            alert("do it yourself");
        }
    }

    return addBookmarkForBrowser(sTitle, sUrl);
};

function set_window() {
    var rootEl = f.body;
    _docHeight = ((rootEl.scrollTop == 0) ? rootEl.clientHeight : rootEl.scrollHeight);
    _docWidth = ((rootEl.scrollLeft == 0) ? rootEl.clientWidth : rootEl.scrollWidth);
    UI.window_w = _docWidth;
    UI.window_h = _docHeight;
};

function set_div_x_y(x, y, a1) {
    var rootEl = f.body;
    if (rootEl.scrollTop > y) {
        y += rootEl.scrollTop;
    }
    f.getElementById(a1).style.left = x;
    f.getElementById(a1).style.top = y;
    f.getElementById(a1).style.display = "block";
};

function mouse_xy(x, y) {
    if (x != undefined) {
        UI.mouse_x = x;
    }
    if (y != undefined) {
        UI.mouse_y = y;
    }
};

function gshow_item_lay() {
    set_window();
    x = UI.window_w / 2 - (350 / 2);
    y = UI.window_h / 2;
    p_s(x, y, 480);
};

function show_item_lay() {
    set_window();
    x = UI.window_w / 2 - (350 / 2);
    y = UI.window_h / 2;
    p_as(x, y, 480);
};